package com.wormhole.wormholemanagement.entity;

import com.wormhole.wormholemanagement.utils.JsonConverter;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Setter
@Getter
@Entity
@Table(name = "operation_logs", indexes = {
        @Index(name = "idx_operator_id", columnList = "operator_id"),
        @Index(name = "idx_operation_type", columnList = "operation_type"),
        @Index(name = "idx_table_name", columnList = "table_name"),
        @Index(name = "idx_operation_time", columnList = "operation_time")
})
public class OperationLog {
    // Getters and Setters
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "log_id")
    private Long logId;

    @Column(name = "operator_id")
    private Long operatorId;
    private String operationType;
    private String tableName;
    private Long recordId;
    private String operationDetails;
    private String ipAddress;
    private LocalDateTime operationTime;

    @Convert(converter = JsonConverter.class)
    @Column(columnDefinition = "json")
    private String extendedData;

}
